package request

// Pool
type Pool struct {
	CorePoolSize   int
	MaxNumPoolSize int
	Queue          []Request
	Reject         interface{}
	MaxWorkerCount int
}

func DefaultPool() *Pool {
	rp := new(Pool)
	rp.CorePoolSize = 2
	rp.MaxNumPoolSize = 2
	rp.MaxWorkerCount = 20000
	rp.Reject = func() {
		panic("Thread limit exceeded replacing blocked worker")
	}
	return rp
}

func (rp Pool) WorkerCount() int {
	return len(rp.Queue)
}

func (rp Pool) execute(r Request) {
	workerCount := rp.WorkerCount()
	if workerCount < rp.MaxWorkerCount {

	} else {
		if rp.Reject != nil {
			rp.Reject.(func())()
		}
	}
}
